/*
 * @Author: mikey.zhaopeng 
 * @Date: 2018-12-30 18:35:06 
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-01-02 23:58:30
 */
import 'package:flutter/material.dart';

import '../constants.dart' show AppColors;

class SearchBar extends StatelessWidget {
  final String placeHolder;
  final bool enable;
  final Function onsubmit;
  const SearchBar(
      {Key key, this.placeHolder = '搜索游戏', this.enable = true, this.onsubmit})
      : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 44.0,
      padding: const EdgeInsets.only(left: 10.0),
      alignment: Alignment.center,
      decoration: BoxDecoration(
          border: Border.all(
              width: 1.0, color: Color(AppColors.searchBarBorderColor)),
          borderRadius: BorderRadius.all(
            Radius.circular(5.0),
          )),
      child: Container(
        alignment: Alignment.center,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Icon(Icons.search,
                color: Color(AppColors.appBarIconTheme), size: 26.0),
            Expanded(
              flex: 1,
              child: Container(
                padding: const EdgeInsets.only(bottom: 2.0),
                child: TextField(
                  maxLines: 1,
                  maxLength: 10,
                  enabled: enable,
                  textAlign: TextAlign.start,
                  decoration: InputDecoration(
                    border: InputBorder.none,
                    contentPadding: const EdgeInsets.all(10.0),
                    hintText: placeHolder,
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
